package uitest
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	import flash.utils.setTimeout;
	import iscript.coreFramework.displays.drawing.LineSegment;
	import iscript.uiFramework.components.button.BaseButton;
	import iscript.uiFramework.components.button.ButtonState;
	import iscript.uiFramework.components.mask.MaskComponent;
	import iscript.uiFramework.components.message.Message;
	import iscript.uiFramework.components.message.MessageType;
	import iscript.uiFramework.components.text.Label;
	import iscript.uiFramework.event.ButtonEvent;
	import iscript.uiFramework.event.UIComponentEvent;
	import iscript.uiFramework.util.layout.LayoutManager;
	import iscript.uiFramework.util.layout.Padding;
	import iscript.uiFramework.util.StringUtil;
	
	public class layoutTest extends Sprite
	{
		
		//[Embed(source = "../../bin/icon/comment.png")]
		
		[Embed(source="../../bin/icon/css.png")]
		private  var iconData:Class;
		
		//[Embed(source = "../../bin/icon/application_view_xp_terminal.png")]
		[Embed(source="../../bin/icon/css.png")]
		private var titleIcon:Class
		
		public function layoutTest()
		{
			draw()
		}
		
		private var b:BaseButton = new BaseButton()
		private var b2:BaseButton = new BaseButton()
		
		//private var msg:Message = new Message();
		
	
		
		private function draw():void
		{
			var lineRect:LineSegment = new LineSegment();
			lineRect.thickness = 1;
			lineRect.fillColor = 0xff99ff
			 
	 
			var r:Rectangle = new Rectangle(100, 100, 400, 300);
			
			//	 var  padding:Padding = new Padding();
			
			// trace(r.top ,r.right,r.left,r.bottom,r.topLeft);
			
			 //  lineRect.drawRectangle(this.graphics,r );
			
			UIaddToStage()
		
		}
		
		private function UIaddToStage():void
		{
			var  label:Label = new Label();
			label.text = "mine label !" 
			label.render(this);
			
			
			b.x = 120
			b.y = 20
			b.width =  50;
			b.height = 25
			//b.border = true;
			b.textLabel.color = 0x3A815A;
			// b.buttonLabel.text = "Raymond Button";
			//b.buttonLabel.text = "按钮测试";
			//b.buttonLabel.opaqueBackground = 0x990000
			b.textLabel.icon = Bitmap(new iconData()).bitmapData
			//b.padding.left = 50;
			//b.padding.right = 50;
			//b.setAlignLabel(LayoutManager.BL);
			b.textLabel.bold = true
			b.textLabel.italic = false;
			
			
			
	        //b.addEventListener(UIComponentEvent.RESIZE,resize)
			b.addEventListener(ButtonEvent.CLICK, function(e:*):void {
			// addMessage();
			/*	 //  b.height = 150
			       //b.buttonLabel.color = 0xE0387B;
				     b.buttonLabel.size = 14
			         b.height = 60
				    b.buttonLabel.text = "Button Controll Test";
					//b.theme = "GoogleTheme"
					b.setAlignLabel(LayoutManager.CC)
				    b.disabled = true;
 
			        trace(b.width)
					setTimeout(function():void { b.disabled = false }, 2000);*/
					
				 /*  if ( b.buttonLabel.icon == null) {
					   b.buttonLabel.icon = Bitmap(new iconData()).bitmapData
					     b.buttonLabel.text = "123按钮测试09876500000000000XXXXX";
					   }else{
				       b.buttonLabel.icon = null
					   }*/							
				 
				})
			b.render(this);
				//addChild(b)
			
			
			trace(b.width)
			
			
			//b.dispose()
			//trace(b.Disposed)
			
			b2.x = 120;
			b2.y = 100
			b2.textLabel.text = "我是第2个按钮";
			b2.addEventListener(ButtonEvent.CLICK, function(e:ButtonEvent):void {
				addMessage();
					//b.state =  ButtonState.DISABLED
					trace(b2.width)
					b2.width=100
					trace(b2.width)
				})
			b2.render(this);
				//addChild(b2)
			//trace(b2.width)
			
			
		
			
		/*	
			b2.y = 20
			b2.width = 100;
			b2.x = b.width + b.x
			b2.height = 50
			addChild(b2)
			
			var lineRect:LineSegment = new LineSegment();
			lineRect.thickness = 1;
			lineRect.fillColor = 0xffffff
			
			//var r:Rectangle = new Rectangle(b.x, b.y, b.width, b.height);
			//lineRect.drawRectangle(this.graphics, r);
			
			var sp:Sprite = new Sprite()
			addChild(sp)
			
			lineRect.fillColor = 0x99ffff
			lineRect.drawRectangle(sp.graphics, new Rectangle(0, 0, 120, 20));
		 
			
			
			var label:Label = new Label();
			    label.x = 200;
				label.y = 200;
			    label.text = "Label";
		        label.icon = Bitmap(new iconData()).bitmapData
				label.color = 0x1D5AEB;
				label.underline = true;
				//label.italic = true;
				//label.bold = true;
				label.font = "Arial"
				//label.size = 50;
				//label.color = 0x000000;
			    addChild(label)*/
			
			
	/*		setTimeout(function():void {
					var  textFormat:TextFormat = new TextFormat();
			     textFormat.align =  TextFormatAlign.LEFT;
			     textFormat.size =20
				 textFormat.font ="宋体"
				label.setTextFormat(textFormat)
				},3000)   b.x = 200;
		   b.y = 200;
		   b.addEventListener(ButtonEvent.CLICK, function(e:ButtonEvent):void {
		   trace("click")
		   })
		   addChild(b)
		
		
		   b2.x = 400;
		   b2.y = 200;
		   b2.addEventListener(ButtonEvent.CLICK, function(e:ButtonEvent):void {
		   trace(b.disabled)
		   b.disabled = !b.disabled
		
		   b.width=200
		   b.height= 100
		   })
		 addChild(b2)*/
		
		}
		
		private function resize(e:UIComponentEvent):void 
		{
			trace("resize")
		//	this.dis
		}
		
		private function addMessage():void {
				
		 var msg:Message = new Message();
		//	msg.x = 300;
			//msg.y = 200;
			//msg.width = 600;
			//msg.height = 400;
			msg.title.text ="标签"
			msg.title.icon = Bitmap(new titleIcon()).bitmapData
			msg.title.font = "微软雅黑"
			//msg.theme="GrayTheme"
			msg.type =  MessageType.INFO;
			msg.text = "Are you sure you want to do that? 中文字符测试。"
			//msg.text = "中文字符测试。拉萨款到即发拉萨的减肥啦时间到了饭卡就死定了发送旅客的房间里看书的风景卢卡斯的解放路上的法律框架阿萨德解放啦集散地"
			        // +"中文字符测试。拉萨款到即发拉萨的减肥啦时间到了饭卡就死定了发送旅客的房间里看书的风景卢卡斯的解放路上的法律框架阿萨德解放啦集散地"
			trace("hasChinese:",StringUtil.hasChinese(msg.text))
			//msg.text = "Are you sure you want to do that?拉萨款到即发拉萨的减肥啦时间到了饭卡就死定了发送旅客的房间里看书的风景卢卡斯的解放路上的法律框架阿萨德解放啦集散地"
			/*"12390723958712935719875918753912793857198235798123759123057219835791285792351239072395871293571987591875391279385719823579812375912305721983579128579235"
				     + "拉萨款到即发拉萨的减肥啦时间到了饭卡就死定了发送旅客的房间里看书的风景卢卡斯的解放路上的法律框架阿萨德解放啦集散地"*/
			//msg.titleLabel.text ="拉萨款到即发拉萨的减肥啦时间到了饭卡就死定了发送旅客的房间里看书的风景卢卡斯的解放路上的法律框架阿萨德解放啦集散地"
			msg.render(this)
			//addChild(this.msg);
			
			/*msg.addEventListener(MouseEvent.CLICK,function():void{
												msg.startDrag(); } );*/
			
			}
	
	}

}